package com.liang.pojo;

import java.io.Serializable;
import java.util.List;

public class Page implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int pages;//总页数
	private int total;//总记录数
	private int currentPage;//当前页
	private int pageSize;//每页记录数
	private int size;//当前页的数量（似乎没用的属性）
	private List<User> lists;//每页显示的数据集合
	
	//1.私有setPages，在setTotal时计算出pages
	//2.currentPage和pageSize的构造函数,并做健壮性判断
	//3.获得一个开始角标startIndex
	
	public Page(int currentPage,int pageSize) {
		if(currentPage<=0) {
			this.currentPage=1;
		}else {
			this.currentPage=currentPage;
		}
		if(pageSize<=0) {
			this.pageSize=10;
		}else {
			this.pageSize=pageSize;
		}
	}
	public int getPages() {
		return pages;
	}
	private void setPages(int pages) { //私有
		this.pages = pages;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) { //设置总页数
		this.total = total;
		this.pages=(total%pageSize)==0?(total/pageSize):(total/pageSize+1);
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getSize() {
		return size;
	}
	public void setSize(int size) {
		this.size = size;
	}
	public List<User> getLists() {
		return lists;
	}
	public void setLists(List<User> lists) {
		this.lists = lists;
	}
	
	public int getStartIndex() {
		return (this.currentPage-1)*pageSize;
	}
}
